Skip to content

correctly handle module that only set package.loaded#6

Merged
pygy merged 1 commit into
pygy:masterfrom
boucman:master
Nov 1, 2015
Merged

correctly handle module that only set package.loaded#6
pygy merged 1 commit into
pygy:masterfrom
boucman:master

Conversation

@boucman

@boucman boucman commented Oct 1, 2015

Copy link
Copy Markdown
Contributor

running these two scripts yield different results
(these assume you have luasec installed, apt-get install lua-sec under debian)

print(require("ssl.https"))

will print table: 0x25ef070 (or similar)

require = require("require").require
print(require("ssl.https"))

will print nil

This is because ssl.https uses the "module" function and that function sets package.loaded["ssl.https"] which, in turn, means the function doesn't have to return anything.

According to lua documentation (and the way the original require works) this is a legal thing to do and require should return the value of package.loaded["ssl.https"] in that case

@tst2005

tst2005 commented Oct 1, 2015

Copy link
Copy Markdown
Contributor

Hello,

You fixed the require52 but I think you will got the same issue with the require51 and it needs the same fix.

@tst2005

tst2005 commented Oct 2, 2015

Copy link
Copy Markdown
Contributor

I start to make a full require behavior tests ...
Take a look at https://github.com/tst2005/lua-require-tests

@boucman

boucman commented Oct 2, 2015

Copy link
Copy Markdown
Contributor Author

i'll have a look, but I only use 5.2 on a regular basis...

@boucman

boucman commented Oct 3, 2015

Copy link
Copy Markdown
Contributor Author

ok, fixed

@pygy

pygy commented Oct 3, 2015

Copy link
Copy Markdown
Owner

Thanks, this is a very good catch, quite embarrassing, to be honest :-)

The test suite most welcome. You may want to add package.loaded[modname] = nil after line 19.

I'll review it all tomorrow.

@boucman

boucman commented Oct 6, 2015

Copy link
Copy Markdown
Contributor Author

@pygy are you waiting for a new patch for me with the fix ? i'm not sure what you want

  • you probably mean before line 19, since code after error() wouldn't be reached
  • even if that's the case, we are at a stage where we havn't set package.loaded[modname] ourselves, so we might as well not touch it.

Of course, if you think that's important I can add it, but i'm not 100% convinced...

tst2005 added a commit to tst2005experiments/lua-experiment-fallback that referenced this pull request Oct 7, 2015
@pygy

pygy commented Oct 7, 2015

Copy link
Copy Markdown
Owner

@boucman that was about the test suite, not your patch. At first glance, it looks fine, but I'll have to review it more thoroughly.

I've had a hectic week (baby born earlier today after a problematic pregnancy for my gf. All's fine now :-)), which left me little time for this. Hopefully I'll have time tomorrow evening.

@boucman

boucman commented Oct 8, 2015

Copy link
Copy Markdown
Contributor Author

no worries, take your time... this is already fixed in the local copy of darktable, so we are not blocked by this bug

my question was more because of the first part : i.e did you expect anything from me....

since that's not the case, I'll just wait. No problem

@boucman

boucman commented Oct 31, 2015

Copy link
Copy Markdown
Contributor Author

any news ? (I don't mind, I have a local fix, but other users might get bitten by this bug)

@pygy

pygy commented Oct 31, 2015 via email

Copy link
Copy Markdown
Owner

@boucman

boucman commented Oct 31, 2015

Copy link
Copy Markdown
Contributor Author

awesome, thx

pygy added a commit that referenced this pull request Nov 1, 2015
correctly handle module that only set package.loaded
@pygy pygy merged commit 8ea9a99 into pygy:master Nov 1, 2015
@pygy

pygy commented Nov 1, 2015

Copy link
Copy Markdown
Owner

Thanks a lot. Now I must do the Luarocks dance :-)

@pygy

pygy commented Nov 1, 2015

Copy link
Copy Markdown
Owner

@tst2005 could you send a pull request with your test suite so that you're correctly credited in the Git log and project stats?

@tst2005

tst2005 commented Nov 3, 2015

Copy link
Copy Markdown
Contributor

@pygy ok, see #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants